package com.example.zy.car.base;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by zy on 2016/4/8.
 */
public class BaseActivityManager {
    private static List<BaseActivity> mBaseMyActivities=new ArrayList<>();

    //添加Activity的方法
    public static void addActivity(BaseActivity baseActivity){
        mBaseMyActivities.add(baseActivity);
    }
    //移除Activity的方法
    public static void removeActivity(BaseActivity baseActivity){
        mBaseMyActivities.remove(baseActivity);
    }
    //结束一个Activity方法
    public static void killActivity(Class activityClass){
        Iterator iterator=mBaseMyActivities.iterator();
        while(iterator.hasNext()){
            BaseActivity activity= (BaseActivity) iterator.next();
            if(activity.getClass()==activityClass){
                iterator.remove();
                activity.finish();
            }
        }
    }
    //结束所有的Activity
    public void finishAll(BaseActivity baseActivity){
        for(BaseActivity baseActivity1:mBaseMyActivities){
            baseActivity1.finish();
        }
    }
}
